import mindspore
import numpy as np
import mindspore.nn as nn
from mindspore import Tensor
import mindspore.ops as ops
from mindspore.nn import LossBase
from mindspore.ops import functional as F


class TestNet(nn.Cell):
    def __init__(self):
        super(TestNet, self).__init__()

    def construct(self, predict, target):
        mse_loss = F.square(predict - target).mean()
        return [mse_loss]

if __name__ == "__main__":
    loss = TestNet()
    x = np.array([[0,1],[2,3]]).astype(np.float32)
    y = np.array([[0,2],[-1,3]]).astype(np.float32)
    x = Tensor(x)
    y = Tensor(y)
    print(x)
    print(y)
    print(loss(x,y))